/**
 * @author        yangmingchao <amustlang_yang@foxmail.com>
 * @date          2024-01-08 21:09:47
 * Copyright © YourCompanyName All rights reserved
 */
const SUCCESS = 200;

/**
 * 判断接口是否成功
 * @param {*} respone 
 * @returns 
 */
export const isSuccess = (respone) => {
    const { success, code } = respone;
    return code == SUCCESS || success
}

/**
 * 转换成字典
 * @param {*} value 纯字符串数组
 * @returns 
 */
export const transformDict = (value) => {
    return value.map(item => ({ value: item, label: item }))
}

/**
 * 是否图片类型后缀
 * @param {*} sufixx 
 * @returns 
 */
export const isImageType = (sufixx) => {
    const tempSufixx = ['bmp', 'jpg', 'png', 'tif', 'gif', 'pcx', 'tga', 'exif', 'fpx', 'svg', 'psd', 'cdr', 'pcd', 'dxf', 'ufo', 'eps', 'ai', 'raw', 'WMF', 'webp', 'avif', 'apng'];
    return tempSufixx.includes(sufixx)
}

/**
 * 获取文件后缀
 */
export function getFileSufixx(fileName){
   return fileName.substring(fileName.lastIndexOf('.') + 1)
}